|
THE BASIC STAMP AND A QUICK AND DIRTY SCHOOL DEMO
THE BASIC STAMP AND A QUICK AND DIRTY
SCHOOL DEMO
Updated
to Rev. 2.0
A co-worker and I decided that we would go together to
his and my
daughters school s on career day. We are both Engineers (He Software,
and I Hardware) and we are going to try and describe the many jobs
in the fast and furious world of Engineering.
I decided that one of the "show and tell" items
I wanted to bring was a disk drive. I know that alot of people have always
wanted to pry open a drive and see what all is in there.
But I didn't want to just bring a static
display....I wanted people to see it in action. I wanted to show them a
drive doing random seeks. I wanted them to see what it is they might hear
happening in their own PC at home as their disks thrash to provide the
date they ask for. I wanted to show them why it was important to defragment
their drives.
( Ok, I know what your saying at this
point.....this guy is a nut. Perhaps...but the Stamp made this project
so simple, I really wasn't as crazy to do it as you might think)
Info on ST506 Drives/Interfaces
Where else would you find this sort of info...but out
on the web!
I found the following info:
Info on Basic Stamps
Disk Demo Operation
The project is quite simple really. I wanted to take
the cover off of a disk, and drive the disk in a manner that would make
it appear as if it was operational.
This meant looking at drive status (Ready,
On-Track, and TRACK0) would have to occure. It also meant that
I had to control the drive with the direction and step lines. All track
info would have to be kept by the software.
The software was easy. The stamp would do the following:
Recalibrate the drive to track 0
Do a sequence (look-up table)
of 50 Psudorandom seeks (to look random/real)
Go back and do it all again....forever!
Stamp Program
The following is the Stamp I Program written to make
the drive go through the above sequence.
'ST506 EXCERSISER DEMO (for demo of a disk drive
' at my daughters school)
'Designed by: Quentin Lewis
' http://www.tiac.net/users/bigqueue
' EMAIL: bigqueue@tiac.net
'--------------------------------------------------------
'REVISION DATE CHANGE MADE
'-------- ---- -----------
'1.0 Early 1997 Initial Design/Coding
'2.0 10/18/97 Unhappy with seek speed
' and RANDOM...now use
' serout to step disk, and
' my own lookup rather than
' random.
'--------------------------------------------------------
'This program is a disk drive demo program.
'The stamp is connected to an ST506 hard disk, and
'the we do the following:
' - Recalibrate to track 0
' DO THIS FOREVER
' - Look-up track in 52 entry table
' - Seek to track
' - Wait for on-track
' - Delay to simulate reading data
' END LOOP
'
'
'INPUT SIGNALS FROM DRIVE
symbol seek_complete = pin7
symbol track0 = pin6
symbol drive_ready = pin5
'OUTPUT SIGNALS TO DRIVE
symbol step_pin = 4
symbol drive_select = pin3
symbol dir = pin2
'DEFINE PIN STATES
symbol step_in = 0
symbol step_out = 1
symbol select = 0
symbol deselect = 1
symbol seek_not_done = 0
symbol on_track = 0
symbol ready = 0
'DEFINE VARIABLES
symbol current_track = w5
symbol go_to_track = w4
symbol count = w3
symbol num_steps = w2
symbol lookup_count = b2
symbol step_delay = 40
symbol max_track = 600
symbol num_bits = 25 'Number of bit switches in ser_char
symbol read_time = 70 'Simulated read time on track
'---------------------------------------------------------------
' RESET ROUTINE: Set-up pins and get ready to run
'---------------------------------------------------------------
reset:
' debug "Starting RESET!!!",cr
dirs = %00011100 'Set D7:D5, D1:D0=Inputs, and D4:D2=Outputs
pins = %11101011 'Set all pins to 1
sel:
drive_select = select 'Select the drive
' debug "Waiting for drive ready!",cr
wait_for_ready: 'Wait here for disk to be ready
' debug "."
if drive_ready <> ready THEN wait_for_ready
if seek_complete <> on_track THEN wait_for_ready
' debug "READY!",cr
my_drive_ready:
' debug "Starting Recal"
gosub recal 'Goto track0
go_to_track = max_track/num_bits 'Seek to end of disk
go_to_track = go_to_track * num_bits
' debug "Seeking to MAX_CYL",cr
gosub seek
'---------------------------------------------------------------
' MAIN ROUTINE: The main program loop
'---------------------------------------------------------------
main:
for lookup_count = 0 TO 52
main_wait:
if seek_complete <> on_track THEN main_wait
lookup lookup_count,(325,399,200,250,300,400,329,370,450,500,350,375,400,350,400,450,275,188,220,250,39,69,109,499,550,300,400,43,52,79,109,500,400,60,200,300,80,300,250,200,300,399,125,500,77,90,200,100,130,50,500,400,320),go_to_track
go_to_track = go_to_track / num_bits * num_bits
gosub seek 'seek to that track
pause read_time 'Pretend to read data
next
goto main
'---------------------------------------------------------------
' SEEK ROUTINE: Since this is basically a SEEK demo, this
' is where all the action is!
'---------------------------------------------------------------
seek:
' debug "Seeking to ",go_to_track,cr
if current_track = go_to_track THEN seek_comp
' debug "Starting seek",cr
dir = step_out 'Step in by default
if go_to_track > current_track THEN ch_dir
num_steps = current_track - go_to_track 'Get step count
goto past_dir
ch_dir:
dir = step_in 'Step toward track 0
num_steps = go_to_track - current_track 'Get step count
past_dir:
if drive_ready <> ready THEN past_dir
if seek_complete <> seek_not_done THEN past_dir
num_steps = num_steps/num_bits 'How many character times
for count = 1 to num_steps 'Send out the steps
serout step_pin,T600,("UUUUU")
next
seek_comp:
current_track = go_to_track 'Say we are at current track
wait_here:
if seek_complete <> seek_not_done THEN wait_here
' debug "Seek Complete",cr
return 'Return to sender
'---------------------------------------------------------------
' RECALIBRATE ROUTINE: Returns head to track 0
'---------------------------------------------------------------
recal:
if seek_complete <> seek_not_done THEN recal
' debug "."
if track0 = on_track THEN recal_done
dir = step_out 'Step toward track 0
pulsout step_pin,1000
goto recal 'Continue until done
recal_done:
current_track = 0 'Signal that we are at track 0
' debug "Recal Complete",cr
return
|